package com.example.drcbackend.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.drcbackend.Mapper.functionaldependenciesMapper;
import com.example.drcbackend.entity.functionaldependencies;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class GenericConstantCService {
    @Autowired private functionaldependenciesMapper fm;

    public int genericConstantC(int DBid) {
        try {
            LambdaQueryWrapper<functionaldependencies> lqw = new LambdaQueryWrapper<>();
            lqw.eq(functionaldependencies::getDbid, DBid);
            int count = Math.toIntExact(fm.selectCount(lqw));
            return count == 0 ? Integer.MAX_VALUE : count;
        } catch (Exception e) {
            e.printStackTrace();
            return Integer.MAX_VALUE;
        }
    }
}
